shopping_list=[('华为p30',3800),
               ('电脑',16000),
               ('奶茶',15),
               ('披萨',88),
               ('冰淇淋',6),
               ('腾讯会员',13),
               ('烫头优惠券',500),
               ('水杯',37)]
shopping_car=[]
zhifubao=input("请输入支付宝余额")
if zhifubao.isdigit():
    zhifubao=int(zhifubao)
    while True:
        for item in shopping_list:
            print(shopping_list.index(item),item)
        choice=input("请输入你想要购买的商品编号：")
        if choice.isdigit():
            choice=int(choice)
            if choice>=0 and choice<=7:
                if zhifubao>= shopping_list[choice][1]:
                    zhifubao = zhifubao - shopping_list[choice][1]
                    shopping_car.append(shopping_list[choice])
                    print("你把商品%s添加到了购物车，你的支付宝余额是%s"%(shopping_list[choice],zhifubao))
                else:
                    print("你的支付宝余额不足，请重新选择商品")
            else:
                print("商品列表没有这个商品，请重新选择商品")
        elif choice == "q":
            print("-----购物车清单-----")
            for item in shopping_car:
                print(item)
            print("你的支付宝余额%s"%zhifubao)
            break
        else:
            print("你输入的编号有误，请重输")
else:
    print("你输入的余额格式有误，请重输")
